package com.recommended.controller;

import com.recommended.constants.WeChatConstant;
import com.recommended.dto.DataInfoSearchCondition;
import com.recommended.dto.ReturnResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author Administrator
 */
@RestController
public class DataSearchController {
    @Autowired
    private RestTemplate restTemplate;

    @PostMapping("/search")
    public ReturnResult search(DataInfoSearchCondition dataInfoSearchCondition) {
        MultiValueMap<String, Object> map = new LinkedMultiValueMap<>(4);
        map.add("ids", dataInfoSearchCondition.getIds());
        map.add("keyword", dataInfoSearchCondition.getKeyword());
        map.add("page", dataInfoSearchCondition.getPage());
        map.add("limit", dataInfoSearchCondition.getLimit());
        ReturnResult result = restTemplate.postForObject(WeChatConstant.DATA_SEARCH_URL, map, ReturnResult.class);
        return result;
    }
}
